package choco.global.scheduling.trees.abstrees;

import choco.integer.IntDomainVar;

/**
 * The Class Leaf. A leaf represents a task to schedule.
 *
 * @author Arnaud Malapert (arnaud.malapert@emn.fr)
 */
public class Leaf extends AbstractNode{

	public static final int WHITE = 0;

	public static final int GRAY = 1;

	public static final int BLACK= 2;


	/** The choco variable of the task. */
	private final IntDomainVar taskVar;

	/** The consumption of the task. */
	private Long consumption;

	/**
	 * the color of the node
	 */
	private int nodeColor;
	/**
	 * The Constructor.
	 *
	 * @param task the task
	 * @param taskVar it starting time
	 * @param consumption it processing time
	 */
	public Leaf(final int task, final IntDomainVar taskVar, final long consumption,final AbstractNodeInfo infos) {
		super(task,infos);
		this.taskVar = taskVar;
		this.consumption = consumption;
	}

	
	@Override
	public void reset(boolean ectOrLst) {
		infos.reset(this, ectOrLst);
	}

	
	/**
	 * Set the consumption of the task (processing time or energy)
	 * @param consumption
	 */
	public void setConsumption(long consumption) {
		this.consumption = consumption;
	}

	
	/**
	 * @return the nodeColor
	 */
	public final int getColor() {
		return nodeColor;
	}

	/**
	 * @param nodeColor the nodeColor to set
	 */
	public final void setColor(int nodeColor) {
		this.nodeColor = nodeColor;
	}

	/**
	 * @return the consumption
	 */
	public final Long getConsumption() {
		return consumption;
	}


	
	
	/**
	 * @return the taskVar
	 */
	public final IntDomainVar getTaskVar() {
		return taskVar;
	}



	
	
	/**
	 * @see choco.global.scheduling.trees.abstrees.AbstractNode#getDotStyle()
	 */
	@Override
	public String getDotStyle() {
		return "filled";
	}


	/**
	 * @see AbstractNode#dotColor()
	 */
	@Override
	protected String dotColor() {
		switch (nodeColor) {
		case WHITE:return DEFAULT_COLOR;
		case GRAY:return "lightgray";
		case BLACK:return "black";
		default:
			return "";
		}
	}



}
